<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('Listen/index')}">监听列表</a></li>
        	<li class=""><a href="{:url('Listen/add')}">添加监听域名/粉丝页</a></li>
			<li class="active"><a>更改信息</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('Listen/editPost')}">
			<div class="form-group">
				<label for="input-domain" class="col-sm-2 control-label"><span class="form-required">*</span>域名</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-domian" name="domain" value="{$dolist.text}" >
				</div>
			</div>
			<div class="form-group">
				<label for="input-phone" class="col-sm-2 control-label"><span class="form-required">*</span>电话</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-phone" name="phone" value="{$dolist.phone}" >
				</div>
			</div>
			<div class="form-group">
				<label for="input-fburl" class="col-sm-2 control-label"><span class="form-required">*</span>粉丝页链接</label>
				<div class="col-md-6 col-sm-10 " onclick = "operate(event)">
					<volist name="$dolist.fanpages" id="fanpage">
						<div style="display: flex;">
							<input type="text" class="form-control" id="input-fburl" eleId="{$fanpage.id}" name="fanpages[]" value="{$fanpage.text}" >
							<button type="button" class="btn min fa fa-minus"></button>
						</div>
					</volist>
					<button type="button" class="add btn input-div fa fa-plus"></button>
				</div>

			</div>

			<div class="form-group">
				<label for="input-is_listen" class="col-sm-2 control-label"><span class="form-required">*</span>是否监听</label>
				<div class="col-md-6 col-sm-10">
					<select class="form-control" name="is_listen">
						<option value="1" <?php if ($dolist['is_listen']==1) {echo "selected";}?> >监听</option>
						<option value="0" <?php if ($dolist['is_listen']==0) {echo "selected";}?> >不监听</option>
					</select> 
				</div>
			</div>
			
			<div class="col-sm-offset-2 col-sm-10">
				<input type="hidden" name="id" value="{$dolist.id}" />
				<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
				<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
			</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script type="text/javascript">
	    function operate(e){
	    	var tag = e.target;
	    	// console.log(tag);
	    	if(tag.nodeName.toLowerCase() == 'button'){
	    		// check class
	    		if(tag.className.indexOf('add')!== -1){
	    			var line = `
				        <div style="display: flex;">
				            <input type="text" class="form-control" id="input-fburl" name="fanpages[]" value="" required>
											<button type="button" class="btn fa fa-minus"></button>
						</div>`;
			        $('.input-div').before(line);
	    		}else if(tag.className.indexOf('min')!== -1){
	    			// deleteEFanpage(tag);
	    			var tnode = tag.parentNode;
	    			tnode.parentNode.removeChild(tnode);
	    		}
	    	}
	    }

	    // function deleteEFanpage(node){
	    // 	var ele = $(node);
	    // 	var sibling = ele.siblings();
	    // 	var tvalue = sibling.
	    // }
	</script>
</body>
</html>
